//
//  ADCollectionViewCell.m
//  AdultStore
//
//  Created by apple on 15/5/16.
//  Copyright (c) 2015年 apple. All rights reserved.
//

#import "ADCollectionViewCell.h"
#import "UIViewAdditions.h"
#import "UIImage+Helper.h"
#import "FXTHeader.h"
@interface ADCollectionViewCell()
@property(nonatomic,assign)float scale;
@end
@implementation ADCollectionViewCell
-(id)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        [self initView];
        [self addObserver:self forKeyPath:@"selected" options:NSKeyValueObservingOptionNew context:nil];
    }
    return self;
}
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
    if ([keyPath isEqualToString:@"selected"]) {
        NSNumber *select = [change objectForKey:@"new"];
        BOOL s = [select integerValue];
        _BackImage .highlighted = s;
    }
}
-(void)dealloc{
    [self removeObserver:self forKeyPath:@"selected"];
}
-(void)initView{
    _scale=Scale;
    
    _BackImage=[[UIImageView alloc]initWithFrame:CGRectZero];
    //_BackImage.highlightedImage=[UIImage ImageForColor:pinkTextColor];
   // _BackImage.contentMode=UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:_BackImage];
    
    _NameLabel=[[UILabel alloc]init];
    _NameLabel.textAlignment=NSTextAlignmentCenter;
    _NameLabel.font=DefaultFont(self.scale);
    _NameLabel.backgroundColor=[UIColor clearColor];
    [self.contentView addSubview:_NameLabel];
}
-(void)layoutSubviews{
    _BackImage.frame=CGRectMake(self.width/2-21*self.scale, self.height/2-31*self.scale, 42*self.scale, 42*self.scale);
    _NameLabel.frame=CGRectMake(5, _BackImage.bottom+3*self.scale, self.width-10, 20*self.scale);
}

@end
